package com.kds.smarthome.common;

import com.fasterxml.jackson.annotation.JsonValue;

public enum StatisticsType {
    ACCUMULATE("accumulate", "累计值"),
    DIRECT("direct", "直接值"),
    EXPRESSION("expression", "表达式");

    private final String code;
    private final String desc;

    StatisticsType(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    @JsonValue
    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static StatisticsType fromCode(String code) {
        for (StatisticsType type : values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown StatisticsType code: " + code);
    }
} 